package com.can.unsafe;


import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

//java.util.ConcurrentModificationException
public class MapTest {

    public static void main(String[] args) {
        //map 是这样用的吗? 不是，工作中不用HashMap
        //默认等价于什么？new HashMap<>(16,0.75);
        //加载因子、初始化容量
//      Map<String,Object> map = new HashMap<>(16,0.75f);
        //解决并发问题
//        Map<String,Object> synmap = Collections.synchronizedMap(new HashMap<>());
        Map<String,Object> map = new ConcurrentHashMap<>();

        for (int i = 1; i < 30; i++) {
            new Thread(()->{
                map.put(Thread.currentThread().getName(), UUID.randomUUID().toString().substring(0,5));
                System.out.println(map);
            },String.valueOf(i)).start();
        }
    }
}
